//
//  MusicLBTDetailTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/21.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "MusicLBTDetailTableViewCell.h"

@interface MusicLBTDetailTableViewCell()

@property(nonatomic, retain) UILabel *countLabel;

@property(nonatomic, retain) UILabel *titleLabel;

@property(nonatomic, retain) UILabel *singerName;

@property(nonatomic, retain) UIImageView *image;

@property(nonatomic, retain) UIImageView *likeImage;

@property(nonatomic, retain) UILabel *likeCount;

@end

@implementation MusicLBTDetailTableViewCell

- (void)dealloc
{
    [_musicSongList release];
    [_countLabel release];
    [_titleLabel release];
    [_singerName release];
    [_image release];
    [_likeCount release];
    [_likeImage release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.countLabel = [[UILabel alloc]init];
        self.countLabel.textColor = [UIColor lightGrayColor];
        self.countLabel.font = [UIFont systemFontOfSize:24 * kWidth];
        [self.contentView addSubview:self.countLabel];
        [_countLabel release];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont systemFontOfSize:20 * kWidth];
        self.titleLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Music_xiazai"]];
        [self.contentView addSubview:self.image];
        [_image release];
        
        self.singerName = [[UILabel alloc]init];
        self.singerName.textColor = [UIColor lightGrayColor];
        self.singerName.font = [UIFont systemFontOfSize:17 * kWidth];
        [self.contentView addSubview:self.singerName];
        [_singerName release];
        
        self.likeImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Music_like"]];
        [self.contentView addSubview:self.likeImage];
        [_likeImage release];
        
        self.likeCount = [[UILabel alloc]init];
        self.likeCount.textColor = [UIColor lightGrayColor];
        self.likeCount.font = [UIFont systemFontOfSize:17 * kWidth];
        [self.contentView addSubview:self.likeCount];
        [_likeCount release];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.countLabel.frame = CGRectMake(30 * kWidth, 25 * kHeight, 40 * kWidth, 30 * kHeight);
    self.titleLabel.frame = CGRectMake(70 * kWidth, 15 * kHeight, self.frame.size.width - 70 * kWidth, 20 * kHeight);
    self.image.frame = CGRectMake(70 * kWidth, 50 * kHeight, 20 * kWidth, 20 * kHeight);
    self.singerName.frame = CGRectMake(self.image.frame.origin.x + 30 * kWidth, self.image.frame.origin.y, 80 * kWidth, 20 * kHeight);
    self.likeImage.frame = CGRectMake(self.singerName.frame.origin.x + 70 * kWidth, self.image.frame.origin.y, 20 * kWidth, 20 * kHeight);
    self.likeCount.frame = CGRectMake(self.likeImage.frame.origin.x + 30 * kWidth, self.image.frame.origin.y, 60 * kWidth, 20 * kHeight);
}

-(void)setMusicSongList:(MusicSongList *)musicSongList
{
    if (_musicSongList != musicSongList) {
        [_musicSongList release];
        _musicSongList = [musicSongList retain];
    }
    self.titleLabel.text = musicSongList.name;
    self.singerName.text = musicSongList.singerName;
    self.likeCount.text = [NSString stringWithFormat:@"%ld.%ld万",[ musicSongList.favorites integerValue] / 10000, [musicSongList.favorites integerValue] / 1000 % 10];
}

-(void)setRow:(NSInteger)row
{
    if (_row != row) {
        _row = row;
    }
    self.countLabel.text = [NSString stringWithFormat:@"%ld", row + 1];
}

@end
